<script setup>
import { RouterLink, RouterView, useRoute, useRouter } from 'vue-router';
import HelloWorld from './components/HelloWorld.vue';
import Layout from '@/components/layout/index.vue';
import { ref } from 'vue';
const route = useRoute();
console.log(route);
const router = useRouter();
const go = () => {
  router.push({ path: '/pinia' });
};

watchEffect(() => {
  console.log(route.fullPath);
  console.log(route.meta);
});

const testRef = ref('xxxx');
console.log(testRef);

// 是否展示layout 如果定义了layout 并且 为false 则不展示，其他情况都展示

// const isDefinedLayout = typeof route.meta.layout !== 'undefined';
// const isNotShowLayout = isDefinedLayout && route.meta.layout === false;

// 什么情况下才会不显示layout？？？ 定义了layout 并且 layout为false  typeof route.meta.layout !== 'undefined'&&route.meta.layout === false
</script>

<template>
  <!-- <div>layout: {{ route.meta.layout }}</div>
  <div>isDefinedLayout:{{ typeof route.meta.layout !== 'undefined' }}</div>
  <div>最终展示与否:{{ !(typeof route.meta.layout !== 'undefined' && route.meta.layout === false) }}</div> -->
  <button @click="go">跳转</button>
  <!-- {{ isNotShowLayout }} -->
  <!-- <RouterView /> -->

  <div>第一层：app.vue</div>
  <RouterView
    v-if="
      (route.path === '/' && Object.keys(route.meta).length === 0) ||
      (route.meta.layout !== 'undefined' && route.meta.layout === false)
    "
  />
  <Layout v-else />
  <!-- <Layout v-if="!(typeof route.meta.layout !== 'undefined' && route.meta.layout === false)">
    <RouterView />
  </Layout>
  <RouterView v-else /> -->
</template>

<style>
#app {
  height: 100%;
}

/* header {
  max-height: 100vh;
  line-height: 1.5;
}

.logo {
  display: block;
  margin: 0 auto 2rem;
}

nav {
  width: 100%;
  margin-top: 2rem;
  font-size: 12px;
  text-align: center;
}

nav a.router-link-exact-active {
  color: var(--color-text);
}

nav a.router-link-exact-active:hover {
  background-color: transparent;
}

nav a {
  display: inline-block;
  padding: 0 1rem;
  border-left: 1px solid var(--color-border);
}

nav a:first-of-type {
  border: 0;
}

@media (width >= 1024px) {
  header {
    display: flex;
    place-items: center;
    padding-right: calc(var(--section-gap) / 2);
  }

  .logo {
    margin: 0 2rem 0 0;
  }

  header .wrapper {
    display: flex;
    flex-wrap: wrap;
    place-items: flex-start;
  }

  nav {
    padding: 1rem 0;
    margin-top: 1rem;
    margin-left: -1rem;
    font-size: 1rem;
    text-align: left;
  }
} */
</style>
